﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Admin.Master" Inherits="System.Web.Mvc.ViewPage<Hotnet.Entity.PictureGroup[]>" %>

<asp:Content ID="Content3" ContentPlaceHolderID="TitleContent" runat="server">
<%
	PictureCategory category = ViewData["Category"] as PictureCategory;
%>
<%=string.Format("<{0}>图片分类 - 图片管理 - Hotent后台管理", category.Name) %>
</asp:Content>

<asp:Content ID="Content4" ContentPlaceHolderID="MainContent" runat="server">

	<%
		PictureCategory category = ViewData["Category"] as PictureCategory;
	%>
	<div class="b1 p3">
		<h2><%=category.Name%></h2>
	</div>
	<p class="tar m5">
		<a href="javascript:createGroup(<%=category.CategoryID%>);">新建图片组</a>
	</p>
	<%Html.BeginForm(); %>
	<div style=" padding:3px;">
		<span>
			图片组名称:<%=Html.TextBox("PictureName") %>
		</span>
		<%--<span>
			所属列表:<%=Html.DropDownList("DefineType", ConvertEnumToSelectList.ComposeSelectListFromEnum<EnumDefineType>().Reverse(), new { id="conditionDefineType"})%>
		</span>--%>
		<span>
			来源网站:<%=Html.DropDownList("SourceFromID", Hotnet.Web.Controllers.Admin.AdminPictureCategoryController.PictureNetList)%>
		</span>
		<span>
			排序:<%=Html.DropDownList("OrderType", ConvertEnumToSelectList.ComposeSelectListFromEnum<EnumOrder>().Reverse())%>
		</span>
		<span>
			状态:<%=Html.DropDownList("IsPublished", ConvertEnumToSelectList.ComposeSelectListFromEnum<EnumPublishState>().Reverse())%>
		</span>
		<input type="submit" value="搜索" />
	
	</div>
	<%Html.EndForm(); %>

	<div class="b1 p5 ma tac" style="width:99%">
		<%if (Model == null || Model.Length == 0){%>
			<div class="tac" style="margin:50px;Color:Red;font-size:20px">
				没有图片组
			</div>
		<%} else { %>
			<% foreach (var item in Model) { %>
			<div class="b1 p3 fl m3 tac" style="background-color:#eee; height:230px;">
				<a href="/AdminPictureGroup/Index/<%=item.GroupID %>" class="b1 hb1 dbk" title="<%=item.Name%>"><img alt="<%=item.Name%>" style="border:0;width:165px;" class="m5" src="<%=item.CoverImage.ThumbnailPath %>"  /></a>
				<a  href="/AdminPictureGroup/Index/<%=item.GroupID %>" style="width:160px;" class="m3 p5 b1 dbk blik" title="<%=item.Name%>"><%=StringUtility.CutString(item.Name, 12)%>
				</a>
				<%--<div style="color:Red;">所属列表:<%=(EnumDefineType)item.DefineType %></div>--%>
					<%if (item.CoverImageID != null || item.CoverImageID != 0) { %>
<%--					<a href="javascript:setBigEye(<%=item.GroupID %>);" id="set<%=item.GroupID %>" <%=(item.IsBigEye?"style='display:none;'":"") %>>设为大眼睛</a>
					<a href="javascript:unsetBigEye(<%=item.GroupID %>);" id="unset<%=item.GroupID %>" <%=(item.IsBigEye?"":"style='display:none;'") %> >取消大眼睛</a> | --%>
					<a href="/AdminPictureGroup/EditPictureList/<%=item.GroupID %>">设置列表</a>&nbsp;&nbsp;
					<%}%>
					<a href="javascript:setPublished(<%=item.GroupID %>);" id="setP<%=item.GroupID %>" <%=(item.IsPublished==1?"style='display:none;'":"") %>>发布</a>
					<a href="javascript:unSetPublished(<%=item.GroupID %>);" id="unsetP<%=item.GroupID %>" <%=(item.IsPublished==1?"":"style='display:none;'") %> >取消发布</a>
					<br />
					<a href="javascript:editGroup(<%=item.GroupID %>,<%=item.DefineType %>);" >编辑</a> | 
					<a href="javascript:confirmDelete('确定要删除该图片组?', '/AdminPictureGroup/Delete/', <%=item.GroupID %>)">删除</a>
			</div>
			<% } %>
			<div class="cb">&nbsp;</div>
		<%}%>
	</div>
	<%Html.RenderPartial("PaginateHelper", ViewData["PaginateHelper"] as PaginateHelper); %>
	   
	<div id="createGroupWin" class="dn">
		<%using (Html.BeginForm("Edit", "AdminPictureGroup", FormMethod.Post, new { id="formMutiple" })){%>
			<input type="hidden" id="groupId" name="groupId"/>
			<input type="hidden" name="categoryId" id="categoryId" />
			<table style="margin:auto" class="list" width="100%">
				<tr>
					<td style="width:35%" align="right">图片组名称:</td>
					<td><input type="text" id="groupName" name="name" /></td>
				</tr>
				<%--<tr>
					<td style="width:35%" align="right">图片所属列表:</td>
					<td><%=Html.DropDownList("DefineType", ConvertEnumToSelectList.ComposeSelectListFromEnum<EnumDefineType>().Reverse())%></td>
				</tr>--%>
				<tr>
					<td style="width:35%" align="right">图片组描述:</td>
					<td><textarea cols="23" rows="5" id="groupDescription" name="description" ></textarea></td>
				</tr>
				<tr>
					<td style="width:35%" align="right">图片组排序:</td>
					<td><input type="text" id="orderInCategory" name="orderInCategory" /></td>
				</tr>
				<tr>
					<td style="width:35%" align="right">图片组来源:</td>
					<td><%=Html.DropDownList("sourceFromID", ViewData["SourceFromList"] as IEnumerable<SelectListItem>, "==请选择==", new { style = "width:170px;" })%></td>
				</tr>
				<tr>
					<td style="width:35%" align="right">图片组Tag:</td>
					<td><input type="text" id="tags" name="tags" /></td>
				</tr>
				<tr align="center">
					<td colspan="2"><input type="submit" value="确定" class="ml3 boxy-button"/><input type="button" value="关闭" onclick="closeGroupWin();" class="ml3 boxy-button"/></td>
				</tr>
			</table>
		<% } %>
	</div>
</asp:Content>

<asp:Content ID="Content1" ContentPlaceHolderID="ScriptContent" runat="server">
	<script type="text/javascript">

		var s_createGroupWin = null;

		$(document).ready(function() {

			$("#conditionDefineType option[value='-1']").html("全部");
		});
		
		function editGroup(t_groupId,defineType) {
			$.getJSON("/AdminPictureGroup/Get/" + t_groupId + "/?" + new Date(), function(group) {
				$("#formMutiple").attr("action", "/AdminPictureGroup/Edit/");
				$("#groupId").val(t_groupId);
				$("#groupName").val(group.Name == null ? "" : group.Name);
				$("#groupDescription").val(group.Description == null ? "" : group.Description);
				$("#orderInCategory").val(group.OrderInCategory);
				$("#categoryId").val(group.CategoryID);
				$("#sourceFromID").val(group.SourceFromID);
				$("#tags").val(group.Tags == null ? "" : group.Tags);
				showWindow('编辑图片组');
			});
		}
		
		function createGroup(categoryId) {
			$("#formMutiple").attr("action", "/AdminPictureGroup/Create/");
			document.getElementById("formMutiple").reset();
			$("#categoryId").val(categoryId);
			showWindow("新建图片组");
		}
		function closeGroupWin() {
			if (s_createGroupWin != null) s_createGroupWin.hide();
		}
		
		function showWindow(title) {
			if (s_createGroupWin == null)
				s_createGroupWin = new Boxy($('#createGroupWin'), { 'title': title, closeText: '[×]', draggable: true }).resize(400, 300);
			else {
				s_createGroupWin.setTitle(title);
				s_createGroupWin.show();
			}
		}

		function setPublished(groupId) {

			$.ajax(
			{
				url: "/AdminPictureGroup/SetPublished/",
				data: "groupId=" + groupId,
				type: "post",
				success: function() {
					document.getElementById("setP" + groupId).style.cssText = "display:none";
					document.getElementById("unsetP" + groupId).style.cssText = "";
				}
			}
			);
		}
		function unSetPublished(groupId) {

			$.ajax(
			{
				url: "/AdminPictureGroup/UnSetPublished/",
				data: "groupId=" + groupId,
				type: "post",
				success: function() {
					document.getElementById("setP" + groupId).style.cssText = "display:none";
					document.getElementById("unsetP" + groupId).style.cssText = "";
				}
			}
			);
		}

		function setBigEye(groupId) {
			$.ajax(
			{
				url: "/AdminPictureGroup/SetBigEye/",
				data: "groupId=" + groupId,
				type: "post",
				success: function() {
					document.getElementById("set" + groupId).style.cssText = "display:none";
					document.getElementById("unset" + groupId).style.cssText = "";
				}
			}
			);
		}

		function unsetBigEye(groupId) {
			$.ajax(
			{
				url: "/AdminPictureGroup/UnsetBigEye/",
				data: "groupId=" + groupId,
				type: "post",
				async:true,
				success: function() {
					document.getElementById("unset" + groupId).style.cssText = "display:none";
					document.getElementById("set" + groupId).style.cssText = "";
				}
			}
			);
		}

		function setCommend(groupId) {
			$.ajax(
			{
				url: "/AdminPictureGroup/SetCommend/",
				data: "groupId=" + groupId,
				type: "post",
				success: function() {
					document.getElementById("setCommend" + groupId).style.cssText = "display:none";
					document.getElementById("unsetCommend" + groupId).style.cssText = "";
				}
			}
			);
		}

		function unsetCommend(groupId) {
			$.ajax(
			{
				url: "/AdminPictureGroup/UnsetCommend/",
				data: "groupId=" + groupId,
				type: "post",
				async: true,
				success: function() {
					document.getElementById("unsetCommend" + groupId).style.cssText = "display:none";
					document.getElementById("setCommend" + groupId).style.cssText = "";
				}
			}
			);
		}
		
		
	</script>
</asp:Content>